<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
     
     function js_ajax(url,method){
           return new Promise((resolve, reject) => {
            let xhr = new XMLHttpRequest();
            xhr.open(method,url,true)
            xhr.send()
            xhr.onreadystatechange=function() {
                if(xhr.status==4){
                    if (xhr.status === 200) {
                        resolve(JSON.parse(xhr.responseText))
                    }else{
                        reject("请求失败"+xhr.status)
                    }
                }
            }
           })
        }

        js_ajax("list.json","get").then(res=>{
            console.log(res);
        }).catch(err=>{
            console.log(err);
        })


    </script>
</body>
</html>